package com.student.work.common;

import lombok.Data;

import java.io.Serializable;

/**
 * 请求响应基础类
 * @date 2020/2/22 13:10
 */
public class BaseResponse<T> implements Serializable {

    private static final long serialVersionUID = 5117636053371320760L;

    private int statusNum;

    private String statusCode;

    private String statusInfo;

    private T data;

    private BaseResponse(ResultCodeEnum resultCode, T data){
        this.statusNum = resultCode.getStatusNum();
        this.statusCode = resultCode.getStatusCode();
        this.statusInfo = resultCode.getStatusInfo();
        this.data = data;
    }

    private BaseResponse(ResultCodeEnum resultCode, String message, T data){
        this.statusNum = resultCode.getStatusNum();
        this.statusCode = resultCode.getStatusCode();
        this.statusInfo = message;
        this.data = data;
    }

    public static <T> BaseResponse<T> result(ResultCodeEnum resultCode, T data){
        return new BaseResponse<>(resultCode, data);
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public int getStatusNum() {
        return statusNum;
    }

    public void setStatusNum(int statusNum) {
        this.statusNum = statusNum;
    }

    public String getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(String statusCode) {
        this.statusCode = statusCode;
    }

    public String getStatusInfo() {
        return statusInfo;
    }

    public void setStatusInfo(String statusInfo) {
        this.statusInfo = statusInfo;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
